using System;
using System.Collections.Generic;
using System.Text;
using Mpi.Common.Collections;
using System.ComponentModel;

namespace Xeml.Document
{
    public class Event : XemlAnnotatableObject, ITimeObject
    {
        private TimeSpan _timePoint;
        private string _label;

        #region Properties
        /// <summary>
        /// A label for this event.
        /// </summary>
        public string Label
        {
            get { return _label; }
            set { _label = value; }
        }


        /// <summary>
        /// The time point where the event occurs.
        /// </summary>
        public TimeSpan TimePoint
        {
            get { return _timePoint; }
            set
            {
                if (_timePoint != value)
                {
                    TimeSpan old = _timePoint;
                    _timePoint = value;
                    OnTimePointHasChanged(old);
                }
            }
        } 
        #endregion

        #region ctors

        public Event()
        {

        }

        public Event(TimeSpan ts)
            : this()
        {
            this._timePoint = ts;
        } 
        #endregion

      

        private EventCollection _collection;
        public EventCollection Collection
        {
            get
            {
                return this._collection;
            }
            internal set
            {
                if (value != _collection)
                {

                    this._collection = value;
                    
                }

            }
        }

       

        #region ITimeObject Members


        public event EventHandler<Mpi.Common.PropertyHasChangedEventArgs<TimeSpan>> TimePointHasChanged;
        protected virtual void OnTimePointHasChanged(TimeSpan oldVal)
        {
            if(TimePointHasChanged != null)
                TimePointHasChanged(this, new Mpi.Common.PropertyHasChangedEventArgs<TimeSpan>(oldVal, this._timePoint));
        }
        #endregion
    }
}
